#ifndef __ALSA_SOUND_H__
#define __ALSA_SOUND_H__

#include "common.h"
#include "wav_parser.h"
#include "sndwav_common.h"
#include "virtualDevice.h"

#define DEFAULT_CHANNELS         (2)
#define DEFAULT_SAMPLE_RATE      (16000)
#define DEFAULT_SAMPLE_LENGTH    (16)
#define DEFAULT_DURATION_TIME    (10)

class AlsaSound
{
public:

    AlsaSound();
    ~AlsaSound();
    int startRecord(const char *filename, int seconds);
	int stopRecord();
	int procOneFrame();
	void startThread();
private:

	int fd;
	SNDPCMContainer_t record;
	pthread_t threadID;


	int sndwavePrepareWAVParams(WAVContainer_t *wav, int seconds);
	void sndwaveWriteHeader(WAVContainer_t *wav);
	void sndwaveRecord(SNDPCMContainer_t *sndpcm, WAVContainer_t *wav, int fd);
	static void *exec(void *arg);
	void run();
	
};

#endif

